// Position routines
function Pos(x,y)
{
    this.x = x;
    this.y = y;
}

function getAbsPos( el )
{
    var pos = new Pos(el.offsetLeft, el.offsetTop);
    elParent = el.offsetParent;
    while( elParent != null )
    {
        pos.x += elParent.offsetLeft;
        pos.y += elParent.offsetTop;
        elParent = elParent.offsetParent;
    }
    return pos;
}

function formatMessage( sFmtString /*, ...*/ )
{
    var sResult = "";
    for (var iPre = 0, i = sFmtString.indexOf('%');
        i != -1;
        iPre = i + 1, i = sFmtString.indexOf('%', iPre))
    {
        sResult += sFmtString.substring(iPre, i);
        ++i; //go to next char
        if (sFmtString.charAt(i) == '%')
        {
            // %% becomes %
            sResult += sFmtString.charAt(i);
            continue;
        }
        var num = parseInt(sFmtString.substr(i));
        sResult += arguments[num];
        i += ("" + num).length - 1; // Because iPre will be set to (i + 1)
    }
    sResult += sFmtString.substr(iPre);
    return sResult;
}

function EventChain()
{
    // ------------------------------------------
    // this utility is used to add several
    // function calls to a specific event, like
    // onload
    // ------------------------------------------
	this.aChain = new Array();
}
EventChain.prototype.add = function(fn){
	this.aChain[this.aChain.length] = fn;
};
EventChain.prototype.exec = function(){
	for(var i=0;i<this.aChain.length;i++){
		var fn = this.aChain[i];
		eval(fn);
	}
};


function cancelEvent(oEvent)
{
    // ------------------------------------------
    // this will halt all events in IE 5.5
    // this will halt most events in IE 5.0
    //  exceptions:  ctrl + click
    //               contextMenu
    // ------------------------------------------
    if (!oEvent) oEvent = window.event;
    if (oEvent) {
        oEvent.returnValue=false;
        oEvent.cancelBubble=true;
    }
    return (false);
}


